import maya.cmds as mc

def getIKhandleJnt(ikhandlename,curvename):
    jntAll=[]
    #ikhandlename=mc.textFieldButtonGrp('ikHandleInfo',q=True, text='')
    effCon=mc.listConnections('%s.endEffector'%(ikhandlename),p=True)[0]
    eff=effCon.split('.')[0]
    endjntCon=mc.listConnections('%s.translateZ'%(eff),p=True)[0]
    endjnt=endjntCon.split('.')[0]

    startjntname=mc.ikHandle(ikhandlename,q=True,sj=True)
    
    whileObj=endjnt
    mc.select(whileObj)
    m=1
    while (whileObj != startjntname):
        jntAll.append(whileObj)
        
        m+=1
        if m==100:
            whileObj = startjntname
            break
        mc.pickWalk(d='up')
        whileObj=mc.ls(sl=True)[0]

    mc.pickWalk(d='up')
    whileObj=mc.ls(sl=True)[0]
    jntAll.append(whileObj)

    return(jntAll)